a=eval(input())
b=eval(input())
c=eval(input())
d=eval(input())
e=eval(input())
if c==1:
    x=a*e+b*d
    y=b*e
    if x%y==0:
        f=x//y
        g=1
    else:  
        gcd=1
        k=2
        while k<=x and k<=y:
            if x%k==0 and y%k==0:
                gcd=k
            k+=1
            f=x//gcd
            g=y//gcd
elif c==2:
    x=a*e-b*d
    y=b*e
    if x%y==0:
        f=x//y
        g=1
    elif a*e-b*d==0:
        g=1
    else:  
        gcd=1
        k=2
        while k<=x and k<=y:
            if x%k==0 and y%k==0:
                gcd=k
            k+=1
            f=x//gcd
            g=y//gcd
elif c==3:
    x=a*d
    y=b*e
    if x%y==0:
        f=x//y
        g=1
    elif a*e-b*d==0:
        g=1
    else:  
        gcd=1
        k=2
        while k<=x and k<=y:
            if x%k==0 and y%k==0:
                gcd=k
            k+=1
            f=x//gcd
            g=y//gcd
else :
    x=a*e
    y=b*d
    if x%y==0:
        f=x//y
        g=1
    elif a*e-b*d==0:
        g=1
    else:  
        gcd=1
        k=2
        while k<=x and k<=y:
            if x%k==0 and y%k==0:
                gcd=k
            k+=1
            f=x//gcd 
            g=y//gcd
print(f)
print(g)